package cn.legend.travel.admin.content.controller;

import cn.legend.travel.admin.content.pojo.param.BannerParam;
import cn.legend.travel.admin.content.service.IBannerService;
import cn.legend.travel.common.web.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(tags = "轮播图管理模块")
@RequiredArgsConstructor
@RequestMapping("/banners")
public class BannerController {
    private final IBannerService bannerService;

    @GetMapping("list")
    @ApiOperation("获取轮播图列表")
    public JsonResult getBannerList() {
        return JsonResult.ok(bannerService.getBannerList());
    }

    @PostMapping("update")
    @ApiOperation("更改轮播图")
    @PreAuthorize("hasAuthority('/banners/update')")
    public JsonResult update(@RequestBody BannerParam param) {
        bannerService.update(param);
        return JsonResult.ok();
    }

}
